package edu.iyte.ceng316.ui.phonebook.dialog;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;

import edu.iyte.ceng316.model.PhoneGroup;



public class PhoneBookDialog extends JDialog {
	DepartmentPanel dp;
    JButton okButton;
    private JPanel m_contentPane;
    
	/**
	 * Create the dialog.
	 */
	public PhoneBookDialog(List<String> departmentNames, PhoneGroup group) {
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setModal(true);
		m_contentPane = new JPanel();
		m_contentPane.setBorder(new MatteBorder(5, 5, 5, 5, (Color) null));
		setContentPane(m_contentPane);
		
		dp = new DepartmentPanel(departmentNames,group);
    	okButton = new JButton("OK");
    	
    	setTitle("Departments");
		setBounds(400, 200, 250, 140);
		
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
		getContentPane().setLayout(gridBagLayout);
		
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.insets = new Insets(0, 0, 5, 5);
		gbc.anchor = GridBagConstraints.NORTHWEST;
		gbc.gridx = 1;
		gbc.gridy = 0;
		getContentPane().add(dp,gbc);
		
		GridBagConstraints gbc2 = new GridBagConstraints();
		gbc2.insets = new Insets(0, 0, 5, 5);
		gbc2.anchor = GridBagConstraints.NORTH;
		gbc2.gridx = 1;
		gbc2.gridy = 1;
		getContentPane().add(okButton,gbc2);
		
		okButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		
	
	}

	public DepartmentPanel getDepartmentPanel() {
		return dp;
	}
	
}
